# -*- encoding utf-8

import socket
import thread


def fun_echo(c, addr):
    while True:
        try:
            str = c.recv(100,)
            if len(str) == 0:
                c.close()
                return 
            print "from  client ",str
            c.send(str)
        except SyntaxError, e:
            c.close()
            print 'close'
            return 
        


s = socket.socket()
s.bind(("61.172.155.243", 9999))
s.listen(1)
while True:
    c, addr = s.accept()
    thread.start_new_thread(fun_echo, (c, addr))